﻿package {
	
	
	import fl.motion.Color;
	import org.papervision3d.core.components.as3.collections.MaterialsListItem
	 import org.papervision3d.materials.utils.MaterialsList
	import org.papervision3d.materials.BitmapAssetMaterial;
	import org.papervision3d.materials.*
	import org.papervision3d.materials.BitmapFileMaterial;
	import org.papervision3d.materials.ColorMaterial;
	import PaperBase;
	import flash.display.*;
	import flash.events.Event;
	import org.papervision3d.objects.DisplayObject3D;
	//import org.papervision3d.objects.parsers.Collada;
	import org.papervision3d.events.FileLoadEvent;
	import org.papervision3d.objects.parsers.DAE;
	import org.ascollada.fx.DaeMaterial;
	
	public class daemain extends PaperBase {
		public var dd:DAE
	   public var universe:DisplayObject3D;
	   public var cow:DisplayObject3D;
	  public var color:Number = 0xFFFFFF
	 //  public var mymat:ColorMaterial
	  // public var mymatlis:MaterialsList
	   public function daemain() {
		 init();
	   }
	   override protected function init3d():void {
	
	  //  mymat = new ColorMaterial(color)
		//mymatlis = new MaterialsList()
		//mymatlis.addMaterial(mymat)
		
		dd = new DAE();
		//dd.addEventListener( Event.COMPLETE, daeCompleteHandler);
		dd.addEventListener(FileLoadEvent.LOAD_COMPLETE, daeCompleteHandler);
		dd.load("models/maya.DAE");
		//dd.material = mymat
		dd.scale = 1
		
		//dd.addChild(mymatlis)
	// 	var daeMaterial = new BitmapFileMaterial("models/plane01completemap.jpg",);
     //   dae.addChild(daeMaterial)
				
		 //dae.scale = 10
		 //dd.scaleX = dd.scaleY = 20;
			//dd.scaleZ = 20;
		 //dae.pitch(-30);
		    universe = new DisplayObject3D();
			universe.addChild(dd);
			default_scene.addChild(universe);
			
		
			
		
		 //cow = new Collada("http://papervision2.com/wp-content/downloads/dae/cow.dae");
		 /*
		 cow = new Collada("models/test.dae");
		 cow = new Dae
		 cow.moveDown(150);
		 
		 cow.pitch(-30);
		 default_scene.addChild(cow);
		 
		 */
		  
	   }
	  private function daeCompleteHandler( e : Event ) {
                      //trace(dd.materialsList())
					  //trace ("this is the mat "+ dd.materialsList())
                        trace("dae loading completed ...\n");
                } 
	   override protected function processFrame():void {
		 universe.yaw(1);
		 //dd.x =300
	   }
	}
}